package com.xd.core.business.controller;


import com.github.pagehelper.Page;
import com.xd.core.business.dto.*;
import com.xd.core.business.service.IUsePrintService;
import com.xd.core.business.vo.UsePrintPageVo;
import com.xd.core.business.vo.UsePrintVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用印表 前端控制器
 * </p>
 *
 * @author zch
 * @since 2025-06-23
 */
@RestController
@RequestMapping("/use-print")
@Slf4j
@Api(tags = "用印管理")
public class UsePrintController {

    @Autowired
    private IUsePrintService usePrintService;

    @PostMapping("/usePrintList")
    @ApiOperation("用印列表分页查询")
    public Page<UsePrintPageVo> usePrintList(@RequestBody UsePrintQueryDto dto) {
        return usePrintService.usePrintList(dto);
    }

    @GetMapping("/getUsePrint/{usePrintId}/{uid}/{typeOfSealUsed}")
    @ApiOperation("查看用印和用印处理回显")
    public UsePrintVo getUsePrint(@PathVariable Integer usePrintId, @PathVariable String uid, @PathVariable String typeOfSealUsed) {
        return usePrintService.getUsePrint(usePrintId, uid, typeOfSealUsed);
    }

    @PostMapping("/checkUsePrint")
    @ApiOperation("用印处理")
    public void checkUsePrint(@RequestBody CheckUsePrintDto dto) {
        usePrintService.checkUsePrint(dto);
        log.info("用印审批成功! 参数{}", dto);
    }

    @PostMapping("/usePrintUrgent")
    @ApiOperation("用印加急")
    public void usePrintUrgent(@RequestBody UsePrintUrgentDto dto) {
        usePrintService.usePrintUrgent(dto);
        log.info("用印加急成功! 参数{}", dto);
    }

    @PostMapping("/addPrintUrgent")
    @ApiOperation("用印申请")
    public Integer addPrintUrgent(@RequestBody AddPrintUrgentDto dto) {
        Integer usePrintId = usePrintService.addPrintUrgent(dto);
        log.info("用印申请成功! 参数{}", dto);
        return usePrintId;
    }

    @PostMapping("/updateRepeat")
    @ApiOperation("修改重新申请用印状态")
    public void updateRepeat(@RequestBody UpdateRepeatDto dto) {
        usePrintService.updateRepeat(dto);
        log.info("修改重新申请用印状态成功! 参数{}", dto);

    }
}